<?xml version='1.0' encoding='iso-8859-1' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../../resources/templates/login.xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:sec="http://www.springframework.org/security/facelets/tags" >

    <ui:define name="menu_horizontal">
        <title>eCoordenador</title>
        <sec:ifAnyGranted roles="ROLE_SERVIDOR,ROLE_ADMINISTRADOR">
            <ui:include src="/site/acessoServidor/menu.xhtml" />
        </sec:ifAnyGranted>
    </ui:define>
    
    <ui:define name="corpo">
        <sec:ifAnyGranted roles="ROLE_SERVIDOR,ROLE_ADMINISTRADOR">
            
            <h:form id="formSalvar">
                <p:growl id="growl" showDetail="true" sticky="true" /> 
                <p:panel  header="Manter Tipos de Atividades Complementares"> 
                    <p:messages id="msgs"/> 
                    <h:panelGrid columns="2" >

                        Tipo de atividade: *<p:inputText  value="#{controllerAtvCompTipo.atvCompTipo.tipo_atividade}" maxlength="20" required="true" requiredMessage="Campo Tipo de Atividade Obrigatorio." style="width: 200px"/>
                        <p:commandButton  value="Salvar" actionListener="#{controllerAtvCompTipo.salvar()}" ajax="true" update="@form"/>

                    </h:panelGrid>
                </p:panel>

                <p:dataTable id="tabela" var="p" value="#{controllerAtvCompTipo.listaDM}" emptyMessage="Nada encontrado..."
                             paginator="true" rows="5"  paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
                     rowsPerPageTemplate="5,10,15"   >
                     <p:column headerText="Cod">
                        <h:outputText value="#{p.id}"/>
                    </p:column>
                    <p:column headerText="Tipo de Atividade">
                        <h:outputText value="#{p.tipo_atividade}"/>
                    </p:column>
                    <p:column>                      
                      <p:commandLink  actionListener="#{controllerAtvCompTipo.prepararAlterar()}"  process="@this" oncomplete="dialogVizualizar.show();" update=":formVizualizar">
                        <p:graphicImage  value="/resources/images/lupa.png" />
                       </p:commandLink>
                        <p:commandLink  actionListener="#{controllerAtvCompTipo.prepararAlterar()}" process="@this" ajax="true" oncomplete="dialogAlterar.show();" update=":formAlterar">
                         <p:graphicImage  value="/resources/images/edit.png" />
                        </p:commandLink>
                        <p:commandLink  actionListener="#{controllerAtvCompTipo.remover()}" ajax="true" process="@this" update="@form">
                        <p:graphicImage  value="/resources/images/delete.png" /> 
                        </p:commandLink>
                    </p:column>
                </p:dataTable>

            </h:form>
        
        
            <p:dialog widgetVar="dialogAlterar" resizable="false" closable="false" modal="true" showEffect="slide" hideEffect="slide">
                <h:form id="formAlterar">
                    <p:panel style="width: 320px;">
                        <p:messages id="msgs"/> 
                        <h:panelGrid columns="2">
                            Tipo de atividade: *
                                <p:inputText value="#{controllerAtvCompTipo.atvCompTipo.tipo_atividade}"/>
                                <p:commandButton value="Alterar" actionListener="#{controllerAtvCompTipo.alterar()}" oncomplete="dialogAlterar.hide()" update=":formSalvar" 
                                                style="margin-top: 30px"/>
                                <p:commandButton value="cancelar" actionListener="#{controllerAtvCompTipo.limpar()}" oncomplete="dialogAlterar.hide()" update=":formSalvar" 
                                                style="margin-top: 30px;margin-left: -35px;"/>
                        </h:panelGrid>
                    </p:panel>
                </h:form>
            </p:dialog>
            
              <p:dialog widgetVar="dialogVizualizar" resizable="false" closable="false" modal="true" showEffect="slide" hideEffect="slide">
                <h:form id="formVizualizar">
                    <p:panel style="width: 320px;">
                        <p:messages id="msgs"/> 
                        <h:panelGrid columns="2">
                                
                                 Cod:
                                 <h:outputText value="#{controllerAtvCompTipo.atvCompTipo.id}"/>
                                 Tipo de atividade: 
                                 <h:outputText value="#{controllerAtvCompTipo.atvCompTipo.tipo_atividade}"/>
                                             
 
                        <p:commandButton value="cancelar" actionListener="#{controllerAtvComp.limpar()}" oncomplete="dialogVizualizar.hide()" update=":formSalvar" 
                                                style="margin-top: 30px;margin-left: 0px;"/>
                        </h:panelGrid>
                    </p:panel>
                </h:form>
            </p:dialog>
            
        </sec:ifAnyGranted>
    </ui:define>
    
</ui:composition>
